
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
  <head>
    <meta charset="utf-8" />
    <title>connection类 &#8212; PyKBase 2.0.0 文档</title>
    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/language_data.js"></script>
    <script type="text/javascript" src="_static/translations.js"></script>
    <link rel="index" title="索引" href="genindex.html" />
    <link rel="search" title="搜索" href="search.html" />
    <link rel="next" title="cursor类" href="cursor.html" />
    <link rel="prev" title="KBase模块" href="kbasemodule.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <div class="section" id="connection">
<h1>connection类<a class="headerlink" href="#connection" title="永久链接至标题">¶</a></h1>
<dl class="class">
<dt>
<em class="property">class </em><code class="sig-name descname">connection</code></dt>
<dd><p>与数据库通信之前，必须先和数据库建立连接</p>
<p>KBase属于不支持事务的数据库,由于DB-API 2.0要求必须实现此方法,因此这类方法是空方法,什么也没有去做.</p>
<dl class="method">
<dt id="connection.close">
<code class="sig-name descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#connection.close" title="永久链接至目标">¶</a></dt>
<dd><p>关闭数据库连接</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>None</strong> – 无.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p>无.</p>
</dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">KBase</span>

<span class="n">conn</span> <span class="o">=</span> <span class="n">KBase</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
<span class="n">conn</span><span class="o">.</span><span class="n">close</span><span class="p">()</span><span class="c1">#关闭连接对象</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="connection.commit">
<code class="sig-name descname">commit</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#connection.commit" title="永久链接至目标">¶</a></dt>
<dd><p>提交当前事务.KBase数据库不支持事务,该接口暂未实现</p>
</dd></dl>

<dl class="method">
<dt id="connection.rollback">
<code class="sig-name descname">rollback</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#connection.rollback" title="永久链接至目标">¶</a></dt>
<dd><p>取消当前事务.KBase数据库不支持事务,该接口暂未实现</p>
</dd></dl>

<dl class="method">
<dt id="connection.cursor">
<code class="sig-name descname">cursor</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#connection.cursor" title="永久链接至目标">¶</a></dt>
<dd><p>创建并返回一个游标或类游标的对象</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>None</strong> – 无.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p>无.</p>
</dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">KBase</span>

<span class="n">conn</span> <span class="o">=</span> <span class="n">KBase</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
<span class="n">cur</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">cursor</span><span class="p">()</span><span class="c1">#创建游标对象</span>
<span class="n">cur</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="n">conn</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</div>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">PyKBase</a></h1>








<h3>导航</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="kbasemodule.html">KBase模块</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">connection类</a></li>
<li class="toctree-l1"><a class="reference internal" href="cursor.html">cursor类</a></li>
<li class="toctree-l1"><a class="reference internal" href="TPIClient.html">TPIClient类</a></li>
<li class="toctree-l1"><a class="reference internal" href="TPIClient_Struct.html">TPIClient_Struct内容</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="kbasemodule.html" title="上一章">KBase模块</a></li>
      <li>Next: <a href="cursor.html" title="下一章">cursor类</a></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">快速搜索</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="转向" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2019, ZZJ.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.2</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="_sources/connection.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>